<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <form action="http://www.biwuit.cn/spboot/userLoginPostRequest" id="form1">
        用户名：<input type="text" name="username"><br>
        密码：<input type="password" name="password"><br>
        <input type="submit" value="提交">
    </form>

    <script>
        const request = new XMLHttpRequest();
        const form1Obj = document.querySelector("#form1")
        const inputs = document.querySelectorAll("input")

        form1Obj.addEventListener("submit",function(e){
            //将
            const FormDataObj = new FormData(form1Obj)
            e.preventDefault();
            request.open("POST","http://www.biwuit.cn/spboot/formDataRequest")
            request.send(FormDataObj)
            request.onreadystatechange = function(){
                if(request.readyState==4&&request.status==200){
                    console.log(request.responseText)
                }
            }
        })

    </script>
</body>
</html>